#!/usr/bin/env python
# encoding: utf-8
import sys, os, requests, socket

socket.setdefaulttimeout(10)    # 10s超时

JSESSIONID = '62B801318A5C838B930C1D79F1433664.2201'
CELL_COOKIE = '903b0944a83f4e44833dd77b2c693e8a|79a9d63182de4eb8|0ebb8a0cc2a258a4d5c7f2321f570943|1'
POST_URL = 'http://f.10086.cn/im5/chat/sendNewGroupShortMsg.action'
USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36'


def SendSMS(touserid, message):
    # 发送短信
    post_data = {'msg':message, 'touserid':touserid}
    cookies = {
               'JSESSIONID': JSESSIONID,
               'cell_cookie': CELL_COOKIE}
    headers = {
               #'User-Agent': USER_AGENT,
               #'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
               #'Origin': 'http://f.10086.cn',
               #'Referer': 'http://f.10086.cn/im5/login/login.action?mnative=0',
               #'Accept-Language': 'zh-CN,zh;q=0.8',
              }

    r = requests.post(POST_URL, data=post_data, headers=headers, cookies=cookies)
    print r.text


if __name__=='__main__':
    # 程序入口
    touserid = ',253364267'
    message = '中文测试123GOOD♂'
    SendSMS(touserid, message)


